<div class="portlet">
    <div class="portlet-actions">
        <button class="btn blue btn-sm" ng-click="lineGrid.add();"><i class="fa fa-plus"></i> 新增</button>
    </div>
    <form class="portlet-search-body" name="queryForm">
        <input type="text" class="form-control search-item" ng-model="lineNo" placeholder="线路编号">
        <input type="text" class="form-control search-item" ng-model="lineName" placeholder="线路名称">
        <select class="form-control search-item" ng-model="lineType"
                ng-options="opt.value as opt.name for opt in options.linetype">
            <option value="">-- 线路类型 --</option>
        </select>
        <div class="search-item">
            <button class="btn btn-sm query" ng-click="lineGrid.query();"><i class="fa fa-search"></i> 查询</button>
            <button class="btn btn-sm reset" ng-click="lineGrid.reset();"><i class="fa fa-eraser"></i> 重置</button>
        </div>
    </form>
    <div class="portlet-body">
        <table ed-grid="lineGrid" class="table table-striped table-bordered table-advance table-hover"
               data-options="url: 'line/query.do', model: 'line', modelText: '线路', form: 'queryForm', modal: 'lineEditModal'">
            <thead>
            <tr>
                <th data-options="field: 'lineNo'">编号</th>
                <th data-options="field: 'lineName'">名称</th>
                <th data-options="field: 'catalog'">分组</th>
                <th data-options="field: 'lineType | code : linetype'">类型</th>
                <th data-options="field: 'mileage'">里程</th>
                <th data-options="field: 'price'">票价</th>
                <th data-options="field: 'plans | plans | to_trusted'">发车方案</th>
                <th data-options="field: '_edit'">操作</th>
            </tr>
            </thead>
        </table>
    </div>
</div>

<div ed-modal="lineEditModal" data-options="title:'　编辑线路',icon:'fa-bus',static:true,width:'900px',defaultButton:false">
    <form action="#" class="form-horizontal w5c-form" w5c-form-validate novalidate name="lineEditForm">
        <div class="form-body">
            <div class="form-group">
                <label class="col-md-2 control-label">线路分组</label>
                <div class="col-md-4">
                    <div ed-typeahead
                         data-options="url:'line/catalogs.do',key:'catalog',value:'catalog', count: '5'"
                         ng-model="line.catalog"/>
                </div>
                <label class="col-md-2 control-label"><span class="required">*</span>类型</label>
                <div class="col-md-4">
                    <select class="form-control search-item" name="lineType" ng-model="line.lineType"
                            ng-options="opt.value as opt.name for opt in options.linetype" required ng-disabled="line.lineId"></select>
                </div>
            </div>
            <div class="form-group">
                <label class="col-md-2 control-label"><span class="required">*</span>线路编号</label>
                <div class="col-md-4">
                    <input type="text" class="form-control" name="lineNo" ng-model="line.lineNo" required
                           ng-maxlength="20">
                </div>
                <label class="col-md-2 control-label"><span class="required">*</span>线路名称</label>
                <div class="col-md-4">
                    <input type="text" class="form-control" name="lineName" ng-model="line.lineName" required
                           ng-maxlength="100">
                </div>
            </div>
            <div class="form-group">
                <label class="col-md-2 control-label">里程</label>
                <div class="col-md-4">
                    <input type="text" class="form-control" name="mileage" ng-model="line.mileage"
                           pattern="^\d{1,2}(\.\d{1,2})?" placeholder="格式：00.00">
                </div>
                <label class="col-md-2 control-label">票价</label>
                <div class="col-md-4">
                    <input type="text" class="form-control" name="price" ng-model="line.price"
                           pattern="^\d{1,2}(\.\d{1,2})?" placeholder="格式：00.00">
                </div>
            </div>
            <div class="form-group" style="border-bottom: 0px;">
                <label class="col-md-2 control-label">线路描述 </label>
                <div class="col-md-10">
                        <textarea rows="2" class="form-control" style="width: 100%;" name="introduce"
                                  ng-model="line.introduce" maxlength="200"></textarea>
                </div>
            </div>
        </div>
        <div class="form-actions">
            <button type="button" class="btn blue" w5c-form-submit="lineGrid.save()">
                <i class="fa fa-save"></i> 保存
            </button>
            <button type="button" class="btn default" ng-click="lineGrid.cancel();">
                <i class="fa fa-times"></i> 取消
            </button>
        </div>
    </form>
</div>

<div ed-modal="linePlanModal" data-options="title:'线路方案',icon:'fa-bus',static:true,width:'720px',defaultButton:false,onShow: 'initCalendar'">
    <form action="#" class="form-horizontal w5c-form" w5c-form-validate novalidate name="linePlanForm"
          style="padding: 0px 5px;">
			<div ed-tab>
			    <ul class="tabTitle">
			        <li class="active">方案信息</li>
			        <li>日期设置</li>
			    </ul>
			    <ul class="tabContent">
			        <li class="active">
			            <div>
				            <div class="form-body">
								<input type="hidden" name="hiddenInput">
					            <div class="form-group">
					                <label class="col-md-2 control-label"><span class="required">*</span>发车时间</label>
					                <div class="col-md-4">
					                    <input type="text" class="form-control" ed-time-picker data-options="format: 'hh:ii'"
					                           name="departTime" ng-model="plan.departTime" required/>
					                </div>
					                <label class="col-md-2 control-label"><span class="required">*</span>开行日期 </label>
					                <div class="col-md-4">
					                    <input type="text" class="form-control" name="startDate" ed-date-picker
					                           ng-model="plan.startDate" required>
					                </div>
					            </div>
					            <div class="form-group">
					                <label class="col-md-2 control-label"><span class="required">*</span>座位数</label>
					                <div class="col-md-4">
					                    <div ed-spinner name="seating" ng-model="plan.seating" data-options="value: 30, step: 1"></div>
					                </div>
					                <label class="col-md-2 control-label"><span class="required">*</span>状态 </label>
					                <div class="col-md-4">
					                    <select class="form-control search-item" name="planStatus" ng-model="plan.planStatus"
					                            ng-options="opt.value as opt.name for opt in options.planstatus | filter:{value:'!3'}"
					                            required></select>
					                </div>
					            </div>
					            <div class="card">
					                <div class="card-header">
					                    <h4>折扣方案</h4>
					                    <button type="button" class="btn blue btn-sm" ng-click="plan.discounts.push({})"><i class="fa fa-plus"></i> 添加</button>
					                </div>
					                <div class="card-item" ng-repeat="discount in plan.discounts">
					                    <i class="glyphicon glyphicon-trash delete" ng-click="plan.discounts.splice($index, 1)"></i>
					
					                    <div class="form-group">
					                        <label class="col-md-2 control-label"><span class="required">*</span>折扣方案</label>
					                        <div class="col-md-4">
					                            <select class="form-control" ed-combobox ng-model="discount.discountId"
					                                    data-options="idField: 'discountId', textField: 'discountName'" ed-data="discounts"></select>
					                        </div>
					
					                        <label class="col-md-2 control-label"><span class="required">*</span>有效截止日</label>
					                        <div class="col-md-4">
					                            <input type="text" class="form-control" ed-date-picker ng-model="discount.expirationDate">
					                        </div>
					                    </div>
					                </div>
					            </div>
					            <div class="card">
					                <div class="card-header">
					                    <h4>退款方案</h4>
					                </div>
					                <div class="card-item">
					                    <div class="form-group">
					                        <label class="col-md-2 control-label"><span class="required">*</span>退款方案</label>
					                        <div class="col-md-4">
					                            <select class="form-control" ed-combobox name="refundRefundId" ng-model="plan.refund.refundId"
					                                    data-options="idField: 'refundId', textField: 'refundName'" ed-data="refunds" required></select>
					                        </div>
					
					                        <label class="col-md-2 control-label"><span class="required">*</span>有效截止日</label>
					                        <div class="col-md-4">
					                            <input type="text" class="form-control" ed-date-picker name="refundExpirationDate" ng-model="plan.refund.expirationDate" required>
					                        </div>
					                    </div>
					                </div>
					            </div>
					        </div>
					        <div class="form-actions">
					            <button type="button" class="btn blue" w5c-form-submit="lineGrid.savePlan()">
					                <i class="fa fa-save"></i> 保存
					            </button>
					            <button type="button" class="btn default" ng-click="linePlanForm.reset();linePlanModal.hide();">
					                <i class="fa fa-times"></i> 取消
					            </button>
					        </div>
			            </div>
			        </li>
			        <li>
						<div ed-calendar>
							<div style="text-align: center;">
								<a class="more" href="#" ng-click="setWorkdayDepart()">
									设置工作日发车
								</a>
								<a class="more" style="margin-left: 40px" href="#" ng-click="setHolidayDepart()">
									设置节假日发车
								</a>
								<a class="more" style="margin-left: 40px" href="#" ng-click="initCalendar()">
									重置
								</a>
							</div>
							<div id="calendar"></div>
						</div>
			        </li>
			    </ul>
			</div>
    </form>
</div>

<div ed-line-stops></div>